package me.zk.practice1.s;

import me.zk.practice1.TreeNode;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @Author: zhang kai
 * @Date: 2023/05/04
 * @Description:
 */
public class S6 {
    public static void main(String[] args) {
        Queue queue = new LinkedList();
        TreeNode t1 = new TreeNode(3,new TreeNode(9),new TreeNode(20,new TreeNode(15),new TreeNode(7)));
        TreeNode t2 = new TreeNode(3,new TreeNode(9),new TreeNode(20,new TreeNode(15),new TreeNode(9)));

//        asQueue(t1,queue);
        treeNodeEqual(t1,t2);
    }

    public static void asQueue(TreeNode node, Queue queue) {
       if (node != null) {
           queue.offer(node);
           System.out.println(node.val);
           if (node.right != null){
               asQueue(node.right, queue);
           }
           if (node.left != null) {
               asQueue(node.left, queue);
           }
       }

    }

    public static void treeNodeEqual(TreeNode node1, TreeNode node2) {
        if (node1 == node2) {
            System.out.println("equals");
        }
        if (node1 != null) {
            if (node1.val != node2.val) {
                System.out.println("No equals");
                return;
            }
            if (node1.right != null){
                treeNodeEqual(node1.right, node2.right);
            }
            if (node1.left != null) {
                treeNodeEqual(node1.left, node2.left);
            }
        }
    }
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == q) {
            return Boolean.TRUE;
        }


        return Boolean.FALSE;
    }

}
